package org.mzyyn.qr.controller;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import org.mzyyn.qr.dto.article.ArticleQueryDTO;
import org.mzyyn.qr.dto.auction.BidDTO;
import org.mzyyn.qr.entity.ArticlePO;
import org.mzyyn.qr.mapper.ArticleMapper;
import org.qr.xiaocao.common.entity.BaseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author lipeng
 * @since 2024-10-15
 */
@RestController
@RequestMapping("/applets")
public class ArticleController {

    @Autowired
    ArticleMapper articleMapper;

    /**
     * 列表
     * @return
     */
    @PostMapping("/article/list")
    public BaseResult list(){
        LambdaQueryWrapper<ArticlePO> query = new LambdaQueryWrapper<>();
        return BaseResult.ok(articleMapper.selectList(query));
    }

    /**
     * 详情
     * @return
     */
    @PostMapping("/article/info")
    public BaseResult list(
            @RequestBody @Validated ArticleQueryDTO articleQueryDTO
    ){
        return BaseResult.ok(articleMapper.selectById(articleQueryDTO.getId()));
    }
}
